<?php
class mlocation extends CI_Model{
	var $location = "location";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_location,$id_submenu,$nama_location,$date_location,$text_location)
	{
		$this->id_location= $id_location;
		$this->id_submenu= $id_submenu;
		$this->nama_location= $nama_location;
		$this->date_location= $date_location;
		$this->text_location= $text_location;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->location, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->location);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_location'=>$this->id_location,
			'id_submenu'=>$this->id_submenu,
			'nama_location'=>$this->nama_location,
			'date_location'=>$this->date_location,
			'text_location'=>$this->text_location
		);
		return $this->db->insert($this->location, $arrayData);
	}
	
	function update($id_location)
	{
		$arrayData = array(
			'id_submenu'=>$this->id_submenu,
			'nama_location'=>$this->nama_location,
			'date_location'=>$this->date_location,
			'text_location'=>$this->text_location
		);
		$this->db->where('id_location', $id_location);
		return $this->db->update($this->location, $arrayData);
	}
        
	function remove($id_location)
	{
		$this->db->where('id_location', $id_location);
		return $this->db->delete($this->location);
	}	
	
	function detail($id_location)
	{
		$this->db->where('id_location', $id_location);
		$query = $this->db->get($this->location);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('nama_location',$name);
		$query = $this->db->get($this->location);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getForWeb($id_submenu)
	{
		$this->db->where('id_submenu', $id_submenu);
		$query = $this->db->get($this->location);	
		return $query->result_array();
	}
	
}
?>